<?php
/*
 * Copyright (c) 2011 Todd Brady
 *
 * PS3Theatre is freely distributable under the terms of the MIT license.
 * For details, see the MIT-Licence web site: http://www.opensource.org/licenses/mit-license.php 
 */
 
	include_once("../includes/db_connect.php");
    
	$tmdbQuery = "SELECT tvdbseries_id from tbl_tvshow_series";
	$tmdbResult=mysql_query($tmdbQuery);
	$random = rand(1,mysql_num_rows($tmdbResult));
	$i = 0;
	
	if(mysql_num_rows($tmdbResult) > 0){
		while($i < $random){
			$tmdbArray = mysql_fetch_array($tmdbResult);
			$i++;
		}
	
		//redirect to get images for tmdb id
		header( 'Location: tvShowImport.php?seriesId='.$tmdbArray['tvdbseries_id'].'&backdrop=Y');
	}else{
		echo '{ "backdropSrc" : "images/tv_bg.jpg" }';
	}
?>